import { createRouter,createWebHashHistory,
  createWebHistory
} from "vue-router";
// createRouter---创建路由对象的
// createWebHashHistory 创建hash模式路由的方法
// createWebHistory 创建历史模式路由的方法
// 准备路由表
const routes=[
  {
    path:"/",
    redirect:"/home"//重定向到首页
  },
  {
     path:"/home",
    name:"home",
    component:()=>import("../views/Home/index.vue")
  },
  {
    path:"/cart",
    name:"cart",
    component:()=>import("../views/Cart/index.vue")
  },
  {
    path:"/cate",
    name:'cate',
    component:()=>import("../views/Cate/index.vue")
  },
   {
    path:"/todolist",
    name:'todolist',
    component:()=>import("../views/todoList/index.vue")
  },
  {
    path:"/fly",
    name:"fly",
    component:()=>import("../views/Fly/index.vue")
  },
  {
    path:"/tang",
    name:"tang",
    component:()=>import("../views/Tang/index.vue")
  },
  {
    path:"/myref",
    name:"myref",
    component:()=>import("../views/myRef/index.vue")
  },
   {
    path:"/mycom",
    name:"mycom",
    component:()=>import("../views/myCom/index.vue")
  },
  {
    path:"/mine",
    name:"mine",
    component:()=>import("../views/Mine/index.vue")
  }
]

// 创建路由对象

let router=createRouter({
  history:createWebHashHistory(), //创建历史模式路由
  routes
})
// 路由全局守卫，路由守卫
router.beforeEach((to,from,next)=>{
  console.log(to,"-----------")
 console.log(from,"*************")
      next();
})  



export default router